<#assign object = doc.objects>
package ${object.package}.service.base;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ${object.package}.service.Upgrade;
import ${object.package}.service.ModelViewService;

public class ModelViewServletBase extends HttpServlet {
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		try {
			ModelViewService service = new ModelViewService();
			Upgrade upgrade = new Upgrade();
			if (req.getParameter("action").equalsIgnoreCase("getFields")) {
				PrintWriter out = resp.getWriter();
				service.getModelFields(req.getParameter("objectName"), out);
				out.flush();
			} else if (req.getParameter("action").equalsIgnoreCase(
					"upgradeTable")) {
				upgrade.upgradeTable(resp.getWriter());
			} else if (req.getParameter("action").equalsIgnoreCase(
					"check")) {
				upgrade.check(resp.getWriter());
			} else if (req.getParameter("action").equalsIgnoreCase(
					"getFindFields")) {
				PrintWriter out = resp.getWriter();
				service.getFindFields(req.getParameter("objectName"), out);
				out.flush();
			} else {
				PrintWriter out = resp.getWriter();
				service.getModelNames(out);
				out.flush();
			}
		} catch (Exception e) {
			// e.printStackTrace();
		}
	}
}
